<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>$set</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <!-- $set可以更改引用数据类型的数据源 -->
    <div class="box">
        <h1>{{msg}}</h1>
        <h1>{{obj.name}}</h1>
        <h1>{{obj.age}}</h1>
        <h1>{{arr[0]}}</h1>
        <button @click="test">更改一下引用数据类型中的值</button>
    </div>
    <script>
        const vm = new Vue({
            el:'.box',
            data:{
                msg:'看黑板了！',
                obj:{
                    name:'诺诺',
                    age:22
                },
                arr:[1,2,3]
            },
            methods:{
                test(){
                    this.$set(this.obj,'age',20);
                    this.$set(this.arr,0,'hjhoij')
                }
            }
        })
        //全局
        Vue.set(vm.obj,'name','圆圆')
    </script>
</body>
</html>